<extend name="./public/frame.html"/>
<block name="content">
	<blockquote class="layui-elem-quote search">
		<div class="layui-inline">
			<input type="text" name="user_phone" lay-verify="required|title" required placeholder="请输入手机号" class="layui-input" id="user_phone">
		</div>
		<div class="layui-inline">
			<button class="layui-btn" data-type="search">搜索</button>
			<button class="layui-btn layui-btn-normal" data-url="{:url('add')}" onclick="add_t(this,'积分规则')">
				积分规则
			</button>
		</div>
	</blockquote>
	<table class="layui-table" lay-data="{width:'auto', height:'auto', url:'{:url('UserIntegral/index')}', page: true, limit: 10, id:'UserIntegral'}" lay-filter="UserIntegral">
		<thead>
		<tr>
			<th lay-data="{field:'id', width:70,fixed: true, sort: true,align:'center',fixed: true}">ID</th>
			<th lay-data="{field:'uid', width:100,align:'center'}">用户UID</th>
			<th lay-data="{field:'user_phone', width:200,align:'center'}">手机号</th>
			<th lay-data="{field:'total_receive_amount', width:200,align:'center'}">总积分（到账 + 未到账）</th>
			<th lay-data="{field:'account_receive_amount', width:200,align:'center'}">已到账（积分）(KM)</th>
			<th lay-data="{field:'unpaid_receive_amount', width:200,align:'center'}">未到账（积分）(分)</th>
			<th lay-data="{field:'amount', width:200,align:'center'}">当前剩余（积分）</th>
			<th lay-data="{fixed:'right', toolbar: '#barDemo', width:150, align:'center'}">操作</th>
		</tr>
		</thead>
	</table>
	<script type="text/html" id="barDemo">
		<a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="look" style="width: 50px">查看</a>
	</script>
	<script>
		layui.use(['form','table'], function () {
			var table = layui.table,form = layui.form;
			table.on('tool(UserIntegral)', function (obj) {
				var data = obj.data;
				var uid = data.uid;
				if (obj.event === 'look') {
					layer.open({
						type: 2,
						title: '查看积分明细',
						shadeClose: true,
						shade: 0.8,
						area: ['100%', '100%'],
						content: '{:url("/admin/UserIntegral/look","uid=")}' + uid //iframe的url
					});
				}
			});
			//搜索
			$('.layui-btn').on('click', function () {
				var user_phone 	= $("#user_phone").val();
				table.reload('UserIntegral', {
					url: '/admin/UserIntegral/index', where: {
						"user_phone": user_phone,
					}
				});
			});
		});
	</script>
</block>
